home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 199_01 / gedio.a < prev    next >
Text File  |  1987-12-15  |  30KB  |  983 lines

  1. ;------------------------------------------------------------------
  2. ; gedio.a  --  Screen and keyboard interface routines for the PC
  3. ;              Specific to DeSmet C
  4. ;
  5. ; last modified - 08/02/87
  6. ;------------------------------------------------------------------
  7.  
  8.  
  9. ;------------------------------------------------------------------
  10. ;                        !!! PLEASE NOTE !!!
  11. ;     This is not quite the same as pcio.a from DeSmet -
  12. ;     I've made some changes here and there for use with ged.
  13. ;
  14. ;     Renamed for ged 1.10
  15. ;
  16. ;     Have changed all Desmet functions that use x,y co-ords
  17. ;     to work as col, row.
  18. ;                                                    Mel Tearle
  19. ;------------------------------------------------------------------
  20.  
  21.  
  22. ;------------------------------------------------------------------
  23. ;                         data starts here
  24. ;------------------------------------------------------------------
  25.  
  26.     dseg
  27.  
  28. ; In this implementation, all special and function keys are translated
  29. ; to the following values.
  30.  
  31. ; control key translations - mapped into cursor-pad.
  32.  
  33. up_char         equ   5     ;arrow up
  34. down_char       equ  24     ;arrow down
  35. left_char       equ  19     ;arrow left
  36. right_char      equ   4     ;arrow right
  37. bol_char        equ  15     ;Home
  38. eol_char        equ  16     ;End
  39. pageup_char     equ  18     ;PgUp
  40. pagedown_char   equ   3     ;PgDn
  41. Del_char        equ   7     ;Del
  42.  
  43. ; function key definitions
  44.  
  45. M1      equ 128
  46. M2      equ 129
  47. M3      equ 130
  48. M4      equ 145
  49. M5      equ 132
  50. M6      equ 133
  51. M7      equ 134
  52. M8      equ 135
  53. M9      equ 136
  54. M10     equ 137
  55.  
  56. ; special keys - toggles and keypress
  57.  
  58. Insert_key      equ 138
  59. Caps_Lock_on    equ 139
  60. Caps_Lock_off   equ 140
  61. Alt_key         equ 146
  62.  
  63. grey_minus      equ 142
  64. grey_plus       equ 143
  65.  
  66.  
  67. ; the table that is used to make the translation
  68. ; note - not all used
  69.  
  70. convert:
  71.         db  72,  up_char
  72.         db  80,  down_char
  73.         db  75,  left_char
  74.         db  77,  right_char
  75.         db  71,  bol_char
  76.         db  79,  eol_char
  77.         db  73,  pageup_char
  78.         db  81,  pagedown_char
  79.         db  78,  grey_plus
  80.         db  74,  grey_minus
  81.         db  82,  Insert_key
  82.         db  83,  Del_char
  83.  
  84.         db  59, M1
  85.         db  60, M2
  86.         db  61, M3
  87.         db  62, M4
  88.         db  63, M5
  89.         db  64, M6
  90.         db  65, M7
  91.         db  66, M8
  92.         db  67, M9
  93.         db  68, M10
  94.         db   0, 255     ;illegal character
  95.  
  96.  
  97. ; equates for bios interface.
  98. ; the interrupt and codes for the screen interface interrupt.
  99.  
  100. video       equ 10h     ;interrupt for dealing with screen
  101.  
  102. mode        equ 0       ;code for setting new screen mode
  103. curtype     equ 1       ;code for setting new cursor type
  104. setcur      equ 2       ;code for addressing cursor
  105. readcur     equ 3       ;code for reading cursor location
  106. readlp      equ 4       ;code for reading light pen position
  107. setpage     equ 5       ;code to select active page
  108. scrollup    equ 6       ;code to scroll screen up
  109. scrolldn    equ 7       ;code to scroll screen nown
  110. readch      equ 8       ;code to read a character from screen
  111. writeach    equ 9       ;code to write char and attributes
  112. writech     equ 10      ;code to write character only
  113. setpal      equ 11      ;code to set new setpal or border
  114. wdot        equ 12      ;code to write a dot
  115. rdot        equ 13      ;code to read a dot
  116. wtty        equ 14      ;code to write as if teletype
  117. state       equ 15      ;code to find current screen status
  118.  
  119.  
  120. ; used in set_video
  121.  
  122. mono_adr     equ  0b000h   ;mono adapter
  123. graph_adr    equ  0b800h   ;graphics adapter*
  124.  
  125. vadrs:       dw  0
  126.  
  127.  
  128. ; the interrupt and codes for the keyboard interface.
  129.  
  130. keyboard     equ 16h     ;interrupt 16 to deal with keyboard
  131.  
  132. cicode       equ 0       ;code for reading a character
  133. cstscode     equ 1       ;reports if character is ready
  134. kbstatus     equ 2       ;get keyboard status - shifts, caplocks
  135.  
  136. kbset:       db  0
  137.  
  138. ; caution: must change column number if 40 column mode
  139.  
  140. crt_cols     equ 80
  141.  
  142. ; variables available to a C88 program
  143.  
  144.         public  scr_cols_, scr_rows_, scr_scrollup_, scr_scrolldown_
  145.         public  scr_mode_, scr_page_, scr_attr_, scr_window_top_
  146.  
  147. scr_cols_:  dw  crt_cols    ;current number of columns
  148.  
  149.  
  150. ; note- make 25 for ms-dos and 24 for cp/m as cp/m steals the bottom
  151. ; line.
  152.  
  153. scr_rows_:  dw  24      ;current number of rows, for ged, was 25
  154. scr_mode_   db  0       ;current screen mode
  155. scr_page_   db  0       ;current page
  156. scr_attr_   db  7       ;current attributes for screen
  157.                         ;7 is white letters on black
  158.  
  159. scr_window_top_ db  1   ;first line to scroll, was 0
  160.  
  161.  
  162. ;------------------------------------------------------------------
  163. ;                          code starts here
  164. ;------------------------------------------------------------------
  165.  
  166.         cseg
  167.  
  168. ;-------------------------------------------------------------------------
  169. ; SCR_SETUP_  scr_setup must be called before any use of any
  170. ;             other routine unless the starting mode is 80X25
  171. ;             character mode (3,4 or 7). Must be called for monochrome
  172. ;             (mode 7) for scr_curson to set a proper cursor.
  173. ;
  174. ; Usage:      mode = scr_setup();
  175. ;-------------------------------------------------------------------------
  176.  
  177. public  scr_setup_
  178. scr_setup_:
  179.         push  bp
  180.         mov   bp, sp
  181.  
  182.         mov   ah,state        ;get current state
  183.         int   video
  184.         mov   scr_mode_, al   ;current mode
  185.         mov   cl, ah          ;make cols a word
  186.         mov   ch,0
  187.         mov   scr_cols_,cx    ;40 or 80 columns
  188.         mov   scr_page_,bh
  189.         mov   scr_attr_,7     ;set to white chars on black
  190.         cmp   al, 4           ;see if a character mode
  191.         jc    got_attr
  192.         cmp   al, 7           ;7 is for graphics mode
  193.         jz    got_attr
  194.         mov   scr_attr_,0     ;attribute is zero in graphics
  195. got_attr:
  196.         mov   ah,0            ;return int containing mode
  197.         push  ax              ;slight detour
  198.         call  set_video_      ;get display address
  199.  
  200.         pop   ax
  201.         pop   bp
  202.         ret
  203.  
  204.  
  205. ;-------------------------------------------------------
  206. ; SCR_TERM_     do any required termination.
  207. ;
  208. ; Usage:        scr_term();
  209. ;-------------------------------------------------------
  210.  
  211. public  scr_term_
  212. scr_term_:
  213.        ret
  214.  
  215.  
  216. ;-------------------------------------------------------
  217. ; SCR_SETMODE_    set a new screen mode
  218. ;
  219. ; Usage:          scr_setmode(new mode);
  220. ;-------------------------------------------------------
  221.  
  222. public  scr_setmode_
  223. scr_setmode_:
  224.         push  bp
  225.         mov   bp,sp
  226.         mov   al,[bp+4]    ;new mode value
  227.         mov   ah,mode
  228.         int   video        ;set new mode
  229.         call  scr_setup_   ;remember new values
  230.         pop   bp
  231.         ret
  232.  
  233.  
  234. ;-------------------------------------------------------
  235. ; SCR_XY_    sets cursor at any location.
  236. ;
  237. ; Usage:         scr_xy(column,row);
  238. ;-------------------------------------------------------
  239.  
  240. public  scr_xy_
  241. scr_xy_:
  242.         push  bp           ;save from bios
  243.         mov   bp, sp
  244.  
  245.         mov   dx,[bp+4]    ;col
  246.         mov   ax,[bp+6]    ;row
  247.         mov   dh, al
  248.  
  249.         mov   bh,scr_page_ ;force page zero
  250.         mov   ah,setcur    ;set cursor location
  251.         int   video        ;call bios
  252.         pop   bp
  253.         ret
  254.  
  255.  
  256. ;-------------------------------------------------------
  257. ; SCR_CLR_      clear entire screen
  258. ;
  259. ; Usage:       scr_clr();
  260. ;-------------------------------------------------------
  261.  
  262. public  scr_clr_
  263. scr_clr_:
  264.      push  bp
  265.      mov   bp, sp
  266.  
  267.      mov   al,0               ;ask for a clear window
  268.      xor   cx,cx              ;start at 0,0
  269.      mov   dh,byte scr_rows_  ;last line
  270.      dec   dh
  271.      mov   dl,byte scr_cols_  ;clear entire width
  272.      dec   dl                 ;last column is width-1
  273.      mov   bh,scr_attr_       ;attributes for new blanks
  274.      mov   ah,scrollup        ;ask for a scrollup to clear
  275.      int   vide